package com.itheima.controller;

import com.itheima.mapper.NursingLevelMapper;
import com.itheima.pojo.*;

import com.itheima.server.INursingLevelService;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.web.bind.annotation.*;

import java.util.List;


@RestController
@RequestMapping("/Level")
public class NursingLevelController
{
    @Autowired
    private NursingLevelMapper nursingLevelMapper;
    @Autowired
    private INursingLevelService nursingLevelService;
    @GetMapping
    public Result list(NursingPage nursingPage){
        PageResult<com.itheima.pojo.NursingLevel> pageResult=nursingLevelService.getList(nursingPage);
        return Result.success(pageResult);
    }
    @PostMapping("/add")
    public Result add(@RequestBody NursingLevel nursingLevel){
        return Result.success(nursingLevelMapper.insert(nursingLevel));
    }
    @GetMapping("/{id}")
    public Result getid(@PathVariable Integer id){
        return Result.success(nursingLevelMapper.selectById(id));
    }
    @PutMapping()
    public Result update(@RequestBody NursingLevel nursingLevel){
        return Result.success(nursingLevelMapper.updateById(nursingLevel));
    }
    @DeleteMapping()
    public Result delete(@RequestParam Integer id){

        nursingLevelMapper.deleteById(id);
        return Result.success("删除成功");
    }


}
